package com.by.controller;

import cn.hutool.core.bean.BeanUtil;
import com.by.bean.FreightInquiry;
import com.by.common.bean.PageBean;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.query.FreightInquiryQuery;
import com.by.service.FreightInquiryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
@Api(tags = "货代询价")
public class FreightInquiryController extends BaseController {
    @Autowired
    FreightInquiryService freightInquiryService;
    @ApiOperation("查询货代询价信息")
    @GetMapping("/freightInquiry")
    public ResultBean get(String quote_coding){
        FreightInquiry freightInquiry = freightInquiryService.get(quote_coding);
        return success("货代询价信息",freightInquiry);
    }
    @ApiOperation("保存货代询价单")
    @PostMapping("/freightInquiry")
    public ResultBean save(@RequestBody FreightInquiry freightInquiry){
        int res = freightInquiryService.save(freightInquiry);
        return saveResult(res);
    }
    @ApiOperation("货代询价列表")
    @PostMapping("/freightInquiry/list")
    public ResultBean query(@RequestBody FreightInquiryQuery query){
        PageBean bean = freightInquiryService.queryByMap(BeanUtil.beanToMap(query));
        return success("货代询价列表",bean);
    }
    @ApiOperation("修改货代询价")
    @PutMapping("/freightInquiry")
    public ResultBean update(@RequestBody FreightInquiry freightInquiry){
        int res = freightInquiryService.update(freightInquiry);
        return updateResult(res);
    }
}
